// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {
    ccclass,
    property
} = cc._decorator;
import {
    Gardener,
    GardenerPopup,
    IGardenerPopup
} from "../gardener/GameGardener"

@ccclass
export default class SettingsPopup extends GardenerPopup implements IGardenerPopup {

    // LIFE-CYCLE CALLBACKS:

    _loading: cc.Node;

    // onLoad () {},

    start() {}

    onBtnClose_Tap() {
        Gardener.closePopup();
    }

    onBtnRequest_Tap() {
        this._loading = Gardener.showLoadingMask();
    }

    onBtnRequestClose_Tap(){
        if(this._loading.isValid)
        Gardener.removeLoadingMask(this._loading);
    }

    onBtnMessageBox_Tap() {
        Gardener.loadMessageBox(GardenerConfig.PrefabMessageBox.P_MESSAGE_BOX, (msgbox) => {
            msgbox && Gardener.showMessageBox(cc.instantiate(msgbox));
        });
    }

    // update (dt) {}

    display() {
        GameLogger.debug('settings popup display');
    }

    dispose() {
        GameLogger.debug('settings popup dispose');
    }
}